/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.io.FileInputStream;

/**
 * <p>Project: jse2303 - Ex5
 * <p>Powered by webrx On 2023-07-24 09:17:01
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex5 {
    public static void main(String[] args) {
        //判断两个文件是不是同一个文件
        //a.zip b.mp4

        //c.jpg d.rar
        boolean f = false;
        try (var isc = new FileInputStream("d:/a.zip"); var isd = new FileInputStream("d:/b.mp4")) {
            if (isc.available() == isd.available()) {
                long s = 0;
                while (isc.read() == isd.read()) {
                    ++s;
                    if (s == 10) {
                        isc.skip(isc.available() / 2 - 10);
                        isd.skip(isd.available() / 2 - 10);
                        s = isc.available() / 2 - 10;
                    }
                    if (s == isc.available()) {
                        f = true;
                        break;
                    }
                }
            }

        } catch (Exception e) {

        }

        System.out.println(f);
    }
}
